#include "StdAfx.h"
#include "UIAppManageTab.h"

#include "main_frame.h"

#include "string\str.h"
#include "..\..\iOS Assistant\Client\device.h"
#include "ZipUnzip/Unzipper.h"
#include "tinyxml/ticpp.h"
#include <io.h>
#include "UISearchTab.h"

#include "CustomControl.h"


CSearchTabUI::CSearchTabUI(CPaintManagerUI& pm):paint_manager_(pm)
{

// 	CDialogBuilder builder;
// 	CContainerUI* pContect = static_cast<CContainerUI*>(builder.Create(_T("tabRecommend.xml"), (UINT)0, this, &paint_manager_));
// 	if(NULL != pContect) 
// 	{
// 		this->Add(pContect);
// 	}
// 	else 
// 	{
// 		this->RemoveAll();
// 	}
	paint_manager_.AddNotifier(this);
}


CSearchTabUI::~CSearchTabUI(void)
{
	paint_manager_.RemoveNotifier(this);
}

void CSearchTabUI::Init()
{
	m_pLayout = static_cast<CTileLayoutUI*>(FindSubControl(_T("searchTileLayOut")));
	if (NULL != m_pLayout)
	{
		m_pLayout->SetItemSize(DuiLib::CSize(104, 120));
	}	
}

void CSearchTabUI::Notify(TNotifyUI& msg)
{
	if(msg.sType == _T("click") )
	{

	}
	else if(msg.sType == _T("itemselect"))
	{


	}
	else if (msg.sType == _T("selectchanged"))
	{

	}
}


void CSearchTabUI::AddElement(SOFTWARENODE* pstSoftNode)
{
	if (pstSoftNode == NULL)
	{
		return;
	}

	CSoftwareNodeUI* pNode = new CSoftwareNodeUI(paint_manager_);
	if( pNode != NULL )
	{
		m_pLayout->Add(pNode);
		pNode->SetSoftwareInfo(pstSoftNode);		
	}
}
void CSearchTabUI::RemoveAllElement()
{
	if (m_pLayout != NULL)
	{
		m_pLayout->RemoveAll();
	}
}